﻿/* ######################################## *\
 * ### Copyright (C) 2009 AJ Ravindiran ### *
\* ######################################## */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AJRavindiran.Jolt.RuneScape.Utilities
{
    /// <summary>
    /// Represents direction related utilities.
    /// </summary>
    public class DirectionUtilties
    {
        #region Fields
        public static readonly sbyte[] DIRECTION_DELTA_X = new sbyte[] { -1, 0, 1, -1, 1, -1, 0, 1 };
        public static readonly sbyte[] DIRECTION_DELTA_Y = new sbyte[] { 1, 1, 1, 0, 0, -1, -1, -1 };
        #endregion Fields

        #region Methods
        /// <summary>
        /// Calculate what direction the given X and Y are in.
        /// </summary>
        public static int GetDirection(int directionX, int directionY)
        {
            if (directionX < 0)
                if (directionY < 0)
                    return 5;
                else if (directionY > 0)
                    return 0;
                else
                    return 3;
            else if (directionX > 0)
                if (directionY < 0)
                    return 7;
                else if (directionY > 0)
                    return 2;
                else
                    return 4;
            else
                if (directionY < 0)
                    return 6;
                else if (directionY > 0)
                    return 1;
                else
                    return -1;
        }
        #endregion Methods
    }
}
